// part1:C06:ex6.21.cpp
// max function.
#include <iostream>
#include <iterator>
#include <string>
#include <ctime>
#include <cstdlib>
using namespace std;

int myCompare(const int val, const int *p) {
  return (val > *p) ? val : *p;
}

int main(void) {
  srand((unsigned)time(NULL));
  int arr[10];
  for (auto &i : arr) {
    i = rand() % 100; 
  }
  cout << "Enter a integer:\n";
  int val;
  cin >> val;
  cout << "max one of the number compare to array> " <<
    myCompare(val, arr) << endl;
  cout << "array elements are:\n";
  for (auto v : arr) {
    cout << v << " "; 
  }
  cout << endl;

  return 0;
}
